package form

const queryTableName = `SELECT name FROM meta_tables WHERE table_id = @table_id and tenant_id = @tenant_id`

const queryDictNames = `SELECT name,is_pk,is_dict_label FROM meta_columns WHERE table_id = @table_id and tenant_id = @tenant_id and (is_pk = 1 or is_dict_label = 1) order by is_pk desc`
const queryColumnName = `SELECT name,is_like_query FROM meta_columns WHERE table_id = @table_id and tenant_id = @tenant_id order by is_pk desc, sort_order asc,column_id asc`

const searchDataSql = `select {columns} from {table_name} where {condition} limit #ps offset #pi`
const searchCountSql = `select count(1) from {table_name} where {condition}`

const inserColumnName = `SELECT name FROM meta_columns WHERE table_id = @table_id and tenant_id = @tenant_id and is_pk = 0 and is_prefab = 0 order by is_pk desc, sort_order asc,column_id asc`
const insertSql = `insert into {table_name} ({columns}) values ({values})`

const updateColumnName = `SELECT name,is_pk FROM meta_columns WHERE table_id = @table_id and tenant_id = @tenant_id and (is_prefab = 0 or is_pk = 1) order by is_pk desc, sort_order asc,column_id asc`
const updateSql = `update {table_name} set {columns} where {condition}`
